import jdk.internal.org.objectweb.asm.tree.IntInsnNode;

import java.util.*;
import java.util.stream.Stream;

public class TextStream {
    public static void main(String[] args) {

        // List 集合系列来创建 Stream 流对象
        List<String> list = new ArrayList<>();
        Collections.addAll(list,"张三","李四","王五","张麻子");
        Stream<String> stream = list.stream();

        // Set 集合系列来创建 Stream 流对象
        Set<String> set = new HashSet<>();
        Collections.addAll(set,"张三","李四","王五","张麻子");
        Stream<String> stream1 = set.stream();

        // Map 集合系列来创建 Stream 流对象
        Map<String,Integer> m = new HashMap<>();
        m.put("张三",19);
        m.put("李四",28);
        m.put("王五",33);
        m.put("张麻子",22);
        //第一种方法:把键值对“封装”成一个整体
        Set<Map.Entry<String,Integer>> entries = m.entrySet();
        Stream<Map.Entry<String,Integer>> stream2 = entries.stream();
        //第二种方法:分别把集合中的键和值全部获取出来，单独放在 List 系列集合中
        Set<String> k = m.keySet();
        Collection<Integer> v = m.values();
        Stream<String> stream3 = k.stream();
        Stream<Integer> stream4 = v.stream();

        // 用数组来创建 Stream 流对象
        String[] strings = new String[]{"张三","李四","王五","张麻子"};
        //第一种方法：用 Arrays.stream() 方法来创建
        Stream<String> stream5 = Arrays.stream(strings);

        //第二种方法：用 Stream.of() 方法来创建
        Stream<String> stream6 = Stream.of(strings);




    }
}
